package xyz.eden.cloud.track.tus.conponent;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import me.desair.tus.server.TusFileUploadService;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import xyz.eden.cloud.track.tus.config.TusProperties;

@Slf4j
@Component
public class TusComponent {

    @Resource
    private TusProperties tusProperties;

    @Bean
    public TusFileUploadService tusFileUploadService() {
        return new TusFileUploadService()
                .withStoragePath(tusProperties.getDirectory())
                .withDownloadFeature()
                .withUploadURI(tusProperties.getServletContextPath() + tusProperties.getUploadUri())
                .withThreadLocalCache(true);
    }
}
